﻿using System;
using System.Collections.Generic;
using System.Text;

namespace designmodule.structuralmodule.Decorator
{
    public abstract class Decorator : Component
    {
        public Component Component { private get; set; }

        public override void Operation()
        {
            if (Component !=null)
            {
                Component.Operation();
            }
        }
    }

    public class ConcreteDecoratorA : Decorator
    {
        private string addedstate;
        public override void Operation()
        {
            base.Operation();
            addedstate = "new state";
            Console.WriteLine("具体a装饰操作");
        }
    }

    public class ConcreteDecoratorB : Decorator
    {
        public override void Operation()
        {
            base.Operation();
            AddedBehavior();
            Console.WriteLine("具体b装饰操作");
        }

        private void AddedBehavior()
        {

        }
    }
}
